package com.personal.controller;

import com.personal.pojo.PersonalData;
import com.personal.pojo.Result;
import com.personal.server.PersonalDateServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class PersonalDataController {

    @Autowired
    private PersonalDateServer personalDataServer;

    @RequestMapping("/personaldate/{id}")
    public Result getPersonalDataByID(@PathVariable Integer id){
        log.info("获取{}的个人信息", id);
        PersonalData p = personalDataServer.getPersonalDataById(id);
        if(p == null){
            return Result.error("未找到该用户的个人信息");
        }
        return Result.success(p);
    }
}
